<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCashflowsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('cashflows', function (Blueprint $table) {
            $table->id()->startingValue(4321);
            $table->unsignedBigInteger('user_id')->comment('关联用户,创建记录的用户');
            $table->unsignedTinyInteger('type')->index()->comment('账单类型 收入 支出');
            $table->unsignedBigInteger('category_id')->index()->comment('收支分类');
            $table->unsignedBigInteger('cashbook_id')->index()->comment('账本ID');
            $table->decimal('amount', 10, 2, true)->comment('金额数量');
            $table->unsignedInteger('year')->comment('年 冗余统计');
            $table->unsignedTinyInteger('month')->comment('月 冗余统计');
            $table->unsignedTinyInteger('day')->comment('日 冗余统计');
            $table->date('date')->comment('日期');
            $table->text('image')->nullable()->comment('图片');
            $table->string('remark')->nullable()->comment('备注');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('cashflows');
    }
}
